package com.songdian.service.impl;

import com.songdian.service.MessageService;
import com.songdian.service.OrderService;
import com.songdian.util.SnowFlake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private MessageService messageService;

    @Override
    public String createOrder() {

        SnowFlake idWorker = new SnowFlake(0, 0);
        String orderNum = idWorker.nextId() + "";
        System.out.println("生成了一个新订单，orderNum：" + orderNum);

        messageService.sendMessage(orderNum);

        System.out.println("订单已加入到消息队列:"  + orderNum);

        return orderNum;
    }

    @Override
    public void getOrder(String id) {

        System.out.println("查询订单");
    }
}
